<?php

/**
* There is still a lot to be done here. This file simply takes an image path
* as a request, parses and and outputs in XML.
*/

require_once('Spectrum.php');

if(isset($_REQUEST['img']))
{

	$img = $_REQUEST['img'];

}else{
	echo "You must specify an image source";
	exit();
	
}

			$spectrum = new Spectrum();
			$spectrum->setImage($img);
			$finalpalette = $spectrum->processImage();
		
			header('Content-type: application/xml; charset="utf-8"',true);

			$xmlOut = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
			
			echo $xmlOut;
			echo "<spectrum>\n";
		
			foreach($finalpalette as $colour)
			{
				echo "<colour>\n";
				echo "<red>".$colour['red']."</red>\n";
				echo "<green>".$colour['green']."</green>\n";
				echo "<blue>".$colour['blue']."</blue>\n";
				echo "<hex>".$colour['hex']."</hex>\n";
				echo "</colour>\n";
			}
			
			echo "</spectrum>\n";
?>